<template>
	<view class="base">
		<view class="top">
			<view class="steps">
				<view class="step1">1</view>
				<view class="step2">
					<view class="step22">

					</view>
				</view>
				<view class="step3"></view>
				<view class="step4">2</view>
			</view>
			<view class="steps-title">
				<view class="step1-title">提交订单成功</view>
				<view class="step4-title">微信付款</view>
			</view>
		</view>
		<view class="center">
			<view class="detail">
				<view class="detail-top">订单金额</view>
				<view class="detail-center">￥{{orderDetail.totalPrice}}</view>
				<view class="detail-bottom">订单提交成功，请在10分钟内完成支付</view>
			</view>
			<view class="pay-option">
				<label>
					<view class="pay-option-left">
						<image src='../../static/images/antFill-wechat.png' mode=""></image>微信支付
					</view>
					<view class="pay-option-right">
						<radio checked="true" class="radio" style="transform:scale(0.7)" />
					</view>
				</label>
			</view>
		</view>
		<button class="goPay" @click="changePayBox">去付款</button>
		<view class="pay-Page" v-if="payBox">
			<view class="pay-Page-title">
				请输入密码
			</view>
			<input type="password" class="pay-Page-input" placeholder="请输入支付密码" v-model="payPwd">
			<view class="pay-Page-click">
				<button type="default" class="pay-Page-button" @click="changePayBox">取消</button> <button type="primary"
					class="pay-Page-button" @click="goPay">确定</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		payOrder
	} from '@/api/system/order.js'
	export default {
		data() {
			return {
				orderDetail: "",
				payBox: false,
				payPwd: ''
			};

		},
		methods: {
			changePayBox() {
				if (this.payBox) {
					this.payPwd = ''
				}
				this.payBox = !this.payBox
			},
			goPay() {
				const data = {
					oid: this.orderDetail.oid,
					payPwd: this.payPwd
				}
				payOrder(data).then(res => {
					if (res.code == 200) {
						this.$modal.msgSuccess('支付成功')
						setTimeout(() => {
							this.$tab.redirectTo('/pages/mine/index')
						}, 1000)
					} else {
						this.$modal.msgError(res.msg)
					}
				})
			},
		},
		onLoad(data) {
			this.orderDetail = JSON.parse(data.data)
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #65A8F2;
	}

	.base {
		margin: 0;
		padding: 0;
		width: 670rpx;
		margin: auto;
	}

	.top {
		height: 140rpx;
		border-radius: 20rpx;
		background-color: rgba(255, 255, 255, 1);
		margin-top: 20rpx;

		.steps {
			display: flex;
			padding-top: 40rpx;

			.step1,
			.step4 {
				width: 40rpx;
				height: 40rpx;
				text-align: center;
				line-height: 40rpx;

				font-size: 28rpx;
				border-radius: 40rpx;
			}

			.step1 {
				background-color: rgba(120, 170, 47, 1);
				color: rgba(251, 251, 251, 1);
				margin-left: 96rpx;
			}

			.step4 {
				color: rgba(16, 16, 16, 0.53);
				font-size: 28rpx;
				border: 1px solid rgba(187, 187, 187, 1);
			}

			.step2,
			.step3 {
				border-top: 2rpx solid rgba(187, 187, 187, 0.49);
				width: 200rpx;
				margin-top: 20rpx;
			}

			.step2 {
				position: relative;
				margin-left: 10rpx;

				.step22 {
					position: absolute;
					animation-name: step2;
					animation-duration: 2s;
					top: -2rpx;
					background-color: rgba(120, 170, 47, 1);
					width: 100%;
					height: 2rpx;
				}
			}

			.step3 {
				margin-right: 10rpx;
			}

		}

		.steps-title {
			display: flex;
			justify-content: space-between;
			height: 60rpx;
			color: rgba(120, 170, 47, 1);
			font-size: 24rpx;
			line-height: 60rpx;
			margin: 0 50rpx;

		}
	}

	.center {
		height: 500rpx;
		background-color: #fff;
		border-radius: 20rpx;
		animation-name: donghua;
		animation-duration: 1s;

		.detail {
			border-bottom: 1px solid #ccc;

			.detail-top {
				width: 130rpx;
				height: 40rpx;
				color: rgba(16, 16, 16, 1);
				font-size: 32rpx;
				margin: 40rpx auto 0;
				padding-top: 40rpx;
			}

			.detail-center {
				text-align: center;
				height: 100rpx;
				line-height: 100rpx;
				color: rgba(236, 13, 13, 1);
				font-size: 60rpx;
				margin: 40rpx 0;
				padding-top: 40rpx;
			}

			.detail-bottom {
				width: 500rpx;
				height: 40rpx;
				color: rgba(16, 16, 16, 1);
				font-size: 28rpx;
				font-family: PingFangSC-regular;
				margin: 40rpx auto 150rpx;
				padding-top: 40rpx;
			}
		}

		.pay-option label {
			display: flex;
			justify-content: space-between;

			.pay-option-left {
				vertical-align: middle;
				margin-top: 26rpx;

				image {
					width: 50rpx;
					height: 50rpx;
					margin: 0 30rpx;
					vertical-align: middle;
				}
			}

			.pay-option-right {
				.radio {
					margin: 20rpx 50rpx 0 0;
				}
			}
		}
	}

	.pay-Page {
		position: absolute;
		top: 300rpx;
		left: calc(50% - 250rpx);
		width: 500rpx;
		height: 300rpx;
		border: 1px solid #ccc;
		border-radius: 20rpx;
		background-color: #fff;

		.pay-Page-title {
			font-size: 40rpx;
			font-weight: 700;
			margin: 20rpx;
			text-align: center;
		}

		.pay-Page-input {
			border: 1px solid #ccc;
			width: 400rpx;
			margin: 20rpx auto;
			padding: 0 20rpx;
			font-size: 30rpx;
			height: 80rpx;
			line-height: 80rpx;
		}

		.pay-Page-click {
			display: flex;
		}

		.pay-Page-button {
			width: 200rpx;
		}
	}

	.goPay {
		width: 640rpx;
		height: 80rpx;
		line-height: 80rpx;
		border-radius: 200rpx;
		margin-top: 200rpx;
		background-color: rgba(255, 255, 255, 1);
		font-size: 30rpx;
		box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
		font-family: Arial;
		border: 1px solid rgba(101, 168, 242, 1);
	}



	@keyframes step2 {
		from {
			width: 0%;
		}

		to {
			width: 100%;
		}
	}

	@keyframes donghua {
		from {
			transform: scale(0.1, 0.1);
		}

		to {
			transform: scale(1, 1);
		}
	}
</style>
